import $ from  'jquery'
const proHost =window.location.protocol+"//"+window.location.host;
const href =window.location.href.split("bpminjs")[0];
const key =href.split(window.location.host)[1];
const publicurl =proHost+key;
const tools= {
    downLoad(bpmnModeler) {
        var downloadLink = $("#downloadBPMN")
        bpmnModeler.saveXML({format:true},function(err,xml) {
            if (err){
                return console.error("could not save bpmn",err)
            }

            tools.setEncoded(downloadLink, "diagram.bpmn",err?null:xml);
        });
    },


    setEncoded(link, name, data)
{
    var encodedData = encodeURIComponent(data);

    if (data) {
        link.addClass('active').attr({
            'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,
            'download': name
        });
    } else {
        link.removeClass('active');
    }
}
}
export  default  tools